package libase.web.jsf.bean;

import java.math.BigDecimal;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import libase.web.jsf.Param;
import libase.web.jsf.ParamCastException;

/**
 *
 * @author aspr0
 */
public abstract class AbstractBean
{
    @PersistenceContext
    protected EntityManager em;
    protected BigDecimal id;
    protected BigDecimal nId;
    protected String sId;

    protected boolean fetchId()
    {
        try
        {
            id = Param.get("id");
        }
        catch (ParamCastException ex)
        {
            return false;
        }

        return true;
    }

    protected boolean fetchStrId()
    {
        try
        {
            sId = Param.gets("id");
        }
        catch (ParamCastException ex)
        {
            return false;
        }

        return true;
    }

    protected boolean fetchNamedId(String name)
    {
        try
        {
            nId = Param.get(name);
        }
        catch (ParamCastException ex)
        {
            return false;
        }

        return true;
    }
}
